package study;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.vo.User;

import javax.servlet.http.HttpServletRequest;

/**
 * 腾讯课堂搜索【咕泡学院】
 * 官网：www.gupaoedu.com
 * 风骚的Mic 老师
 * create-date: 2020/1/6-16:00
 */
@RestController
@RefreshScope
public class HelloController {

    //autoRefreshed 表示自动刷新
    @Value(value = "${key:hello world}")
    private String name;

    @Value(value = "${config.env:22222}")
    private String env;
    @Value(value = "${config.flag:22222}")
    private String common_flag;
    @GetMapping("/say")
    public String sayHello(){
        return "say："+name+"  config.env:"+env+" common_flag:"+common_flag;
    }


    @RequestMapping("/hello")
    public String hello(HttpServletRequest request) {
        String params = request.getHeader("X-Request-Foo");
        String str="server1   参数-X-Request-Foo = " + params ;
        //返回数据
        return str;
    }

    @GetMapping(value = "/user/get")
    public String updateUser1(User user){
        return "get方法：返回用户"+user.toString();
    }
}
